package com.igrowing.maker.generator.file;

import com.igrowing.maker.model.DataModel;

import java.io.File;

public class FileGenerator {






    public static void doGenerate(Object model) throws Exception {
        String projectPath = System.getProperty("user.dir");
        // 整个项目的根路径
        //File parentFile = new File(projectPath).getParentFile();
        // 输入路径
        //String inputPath = new File(projectPath, "yuzi-generator-demo-projects/acm-template").getAbsolutePath();
        String outputPath = projectPath;
        // 生成静态文件
       //FileUtil.copy(inputPath, outputPath,false);
        // 生成动态文件
        String inputDynamicFilePath = projectPath + File.separator +"code-generator-basic"+File.separator+ "src/main/resources/template/MainTemplate.java.ftl";
        String outputDynamicFilePath = outputPath + File.separator + "MainTemplate.java";
        DynamicFileGenerator.doGenerate(inputDynamicFilePath, outputDynamicFilePath, model);
    }

    public static void main(String[] args) throws Exception {
        DataModel mainTemplateConfig = new DataModel();
        mainTemplateConfig.setAuthor("hahah");
        mainTemplateConfig.setLoop(true);
        mainTemplateConfig.setOutputText("求和结果：");
        doGenerate(mainTemplateConfig);
    }

}
